package com.heima.user.controller;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.dtos.AuthDto;
import com.heima.model.user.pojos.ApUser;
import com.heima.user.service.UserAuthService;
import io.swagger.annotations.ApiModelProperty;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
public class UserAuthController {

    @Autowired
    private UserAuthService userAuthService;
    @PostMapping("/list")
    public ResponseResult list(@RequestBody AuthDto dto){
        return userAuthService.list(dto);
    }

    @PostMapping("/authFail")
    public ResponseResult authFail(@RequestBody AuthDto dto){
        return userAuthService.authFail(dto);
    }

    @PostMapping("/authPass")
    public ResponseResult authPass(@RequestBody AuthDto dto){
        return userAuthService.authPass(dto);
    }

    @ApiModelProperty("通过 id 获取用户")
    @GetMapping("/getById")
    public ApUser getById(Integer id){
        log.info("接受到 getById 请求 {}", getClass().getName());
        return userAuthService.getById(id);
    }
}
